<include file="Public/head"/>
<body class="no-skin">
<include file="Public/header"/>
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <include file="Public/sidebar"/>
    <div class="main-content">
        <div class="main-content-inner">
            <!-- #section:basics/content.breadcrumbs -->
            <include file="Public/breadcrumbs"/>

            <!-- /section:basics/content.breadcrumbs -->
            <div class="page-content">
                <include file="Public/set"/>

                <!-- /section:settings.box -->
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                       
                        <div class="space-4"></div>
                        <div class="row">
                            <div style="margin-bottom: 10px;" >
                              <volist name="customer" id="v">
                                            <span class="btn btn-info" style="margin-top: 5px;margin-left: 5px;"><a href="{:U('index',array('shop_sites_id'=>$v['id']))}">{$v['shop_name']} </a></span>
                              </volist>
                            </div>
                            <form id="form" method="post" action="{:U('del')}">
                                <table class="table table-striped table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th class="center"><input class="check-all" type="checkbox" value=""></th>
                                        <th>合作站点店铺名称</th>
                                        <th>平台名称</th>
                                        <th>是否绑定到中台店铺</th>
                                        <th class="center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <style>
                                        .grouptd {
                                            position: relative;
                                        }

                                        .group {
                                            display: inline-block;
                                            width: 100%;
                                        }

                                        .groupselect {
                                            position: absolute;
                                            top: 0;
                                            left: 0;
                                            width: 100%;
                                            height: 100%;
                                            border: 0;
                                        }
                                    </style>
                                    <volist name="list" id="val">
                                        <tr>
                                            <td class="center">
                                                <input class="ids" type="checkbox" name="ids[]" value="{$val['id']}">
                                            </td>
                                            <td>{$val['name']}</td>
                                            <td>{$val['shop_name']}</td>
                                            <td><?php if($val['bind_partner']):?>已经绑定到：{$val['bind_name']}<?php else:?> 否<?php endif;?></td>
                                            <td class="center">
                                                <a href="javascript:pull({$val['id']},'{$val['bind_partner']}');">绑定中台店铺</a>&nbsp;
                                               
                                            </td>
                                        </tr>
                                    </volist>
                                    </tbody>
                                </table>
                            </form>
                          
                            {$page}
                        </div>
                        <!-- PAGE CONTENT ENDS -->
                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <include file="Public/footer"/>

</div><!-- /.main-container -->

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
              <h4 class="modal-title " id="myModalLabel">绑定</h4>
            </div>
            <div class="modal-body">

                    <div class="form-group">
                            <input type="hidden" id="partner_store_id" value=''>
                              <label class="col-sm-3 control-label no-padding-right" for="form-field-10">中台店铺 </label>
                                  <div class="col-sm-8">
                                      <select id="bind_partner" name="bind_partner" class="rcol-xs-10 col-sm-11">
                                          <volist name="option" id="v">
                                             <option value="{$v['id']}" >{$v['name']}</option>
                                          </volist>   
                                        </select>
                                  </div>
                    </div>

                
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span>关闭</button>
              <button type="button" id="btn_submit" class="btn btn-primary tijiao" data-dismiss="modal"><span class="glyphicon glyphicon-floppy-disk" aria-hidden="true"></span>保存</button>
            </div>
          </div>
        </div>
  </div>
<include file="Public/footerjs"/>
<!-- inline scripts related to this page -->
<script type="text/javascript">
        function pull(id,bind_partner){
            var id = id;
            var bind_partner = bind_partner;
            $("#partner_store_id").val(id);
           $('#bind_partner option').each(function(){
                    if( bind_partner == $(this).attr('value') ) {
                        $(this).attr('selected' , true);
                        return false;
                    } 
                 });
      $("#myModal").modal("show");
              
        }
        
     $(".tijiao").click(function(){
          var bind_partner =  $('#bind_partner option:selected').val();
          var id = $('#partner_store_id').val();
        
          $.post("{:U('pull')}", {id:id,bind_partner:bind_partner},function(data){
                if (data.errno ==0)
                {  
                    alert('绑定成功');
                    location.reload();
                } else {

                    G.ui.tips.err(data.error);
                }
            },'json');
      });
</script>
</body>
</html>
